import wx

class MyWin(wx.Window):
    def __init__(self, parent, id):
        wx.Window.__init__(self, parent, id)
#        self.font = wx.NORMAL_FONT
#        size = self.GetClientSize()
        size = wx.Size(400,400)
        print size
        self.buffer = wx.EmptyBitmap(size.width, size.height)
        self.font = wx.Font(10, wx.MODERN, wx.NORMAL, wx.NORMAL, face='Book Antiqua')
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        self.Foo()
    
    def Foo(self):
        dc = wx.BufferedDC(wx.ClientDC(self), self.buffer)
        dc.BeginDrawing()
#        dc = wx.BufferedDC(None, self.buffer)
#        dc.SetBackground(wx.Brush('white'))
        dc.Clear()
        dc.SetFont(self.font)
        dc.SetTextBackground('grey')
        dc.SetTextForeground('blue')
        dc.DrawText('Hello world!', 10, 10)
        for row in range(8):
            line = '%02X: '%(row*32) + ''.join(unichr(row*32+col) for col in range(32))
#            print line
            dc.DrawText(line, 10, row*15+30)
        dc.EndDrawing()

    def OnPaint(self, evt):
        print 'OnPaint'
        dc = wx.BufferedPaintDC(self, self.buffer)
        
#----------------------------------------------------------------------

class MyFrame(wx.Frame):
    def __init__(self, parent):
        wx.Frame.__init__(self, parent, -1, "GUI Test", size=(800,600))
        self.win = MyWin(self, -1)

#----------------------------------------------------------------------

if __name__ == '__main__':
    app = wx.PySimpleApp()
    frame = MyFrame(None)
    frame.Show(True)
    app.MainLoop()
